$(function(){
    queryAccountIncome();
    //AccountAmount();
    getNewUserCount();
    NoIssueCount();
    noorder();
    productCount();
    var acountName = $.cookie('uat');
    $("#acountName").html("Hi，"+acountName);
    /*if( acountName == "admin" ){
        $("#gaiyao1").hide();
        $("#gaiyao2").show();
    }else{
        $("#gaiyao1").show();
        $("#gaiyao2").hide();
    }*/
});

/*
$('#userCountDomain').html("<a href='../business/domain/domain.html'>"+data.userCountDomain+"</a>");*/

//今日充值金额
function queryAccountIncome(){
    var fn="queryAccountIncome";
    var service = {};
    service.day='0';
    service = Commonjs.jsonToString(service);
    var params = Commonjs.getParams(fn,service);//获取参数
    Commonjs.ajaxTrue(weburl, params, function (data) {
        if(data.result=="success"){
            var Count=data.data.total;
            $('#rechargeCount').html("0元");
            var Counts = '<span>'+ Count+'</span>元';
            //$('#rechargeCount').html(Counts);
            $('#rechargeCount').html("<a href='./finance/rechargelist.html?BstartTime=0&BendDate=0'>" + Counts + "</a>");
        }
    });
}

//成交金额
function AccountAmount(){
    //return;
    var fn="queryAccountAmount";
    var service = {};
    service.day='0';
    service.itemId='';//财务类型
    service = Commonjs.jsonToString(service);
    var params = Commonjs.getParams(fn,service);//获取参数
    var data=Commonjs.ajax(weburl,params,false);
    if(data.result=="success"){
        if(data.result=="success"){
            var Count=data.data.total;
            $('#newuser').html(Count+"");
            var Counts = '<span>'+ Count+'</span>';
            $('#newuser').html(Counts);

        }
    }
}
//今日新增会员
function getNewUserCount(){
    var fn="getAccountCount";
    var service = {};
    service.day='0';
    service = Commonjs.jsonToString(service);
    var params = Commonjs.getParams(fn,service);//获取参数
    Commonjs.ajaxTrue(weburl, params, function (data) {
        if(data.result=="success"){
            var Count="";
            $('#newuser').html("");
            Count +=  data.data + '个';
            //$('#newuser').append(Count);
            $('#newuser').html("<a href='./user/userlist.html?BstartTime=0&BendDate=0'>" + Count + "</a>");
        }
    });
}

//未处理工单
function NoIssueCount(){
    var fn="queryIssueCount";
    var service = {};
    service.state='1';
    service = Commonjs.jsonToString(service);
    var params = Commonjs.getParams(fn,service);//获取参数
    Commonjs.ajaxTrue(weburl, params, function (data) {
        if(data.result=="success"){
            var Count="";
            $('#noIssue').html("");
            $('#noIssue').html("<a href='./workorder/wokeorderlist.html?workOrderState=1'>" + data.data + "</a>");
        }
    });
}

//未处理订单
function noorder(){
    var fn="queryOrderCount";
    var service = {};
    service.handleStatus='N';
    service = Commonjs.jsonToString(service);
    var params = Commonjs.getParams(fn,service);//获取参数
    Commonjs.ajaxTrue(weburl, params, function (data) {
        if(data.result=="success"){
            var Count="";
            $('#noorder').html("");
            //Count =  data.data;
            //$('#noorder').append(Count);
            $('#noorder').html("<a href='./order/orderlist.html?handleStatus=N'>" + data.data + "</a>");
        }
    });
}

//产品统计
function productCount(){
    var todayNewDiy=0;

    var countDiy=0;

    var sevenNewDiy=0;

    var sevenExpiredDiy=0;

    var expiredDiy=0;

    //查询自定义产品数量
    fn="queryNewDiyState";
    var service = {};
    service = Commonjs.jsonToString(service);
    params = Commonjs.getParams(fn,service);//获取参数
    Commonjs.ajaxTrue(weburl, params, function (data) {
        if(data.result=="success"){
            countDiy = data.data.all;
            todayNewDiy = data.data.openToday;
            sevenNewDiy = data.data.openSevenDay;
            sevenExpiredDiy = data.data.expireSevenDay;
            expiredDiy = data.data.countExpired;

            $('#today_new_diy').html("<a href='./diy/index.html?BstartTime=0&BendDate=0'>" + todayNewDiy + "</a>");
            $('#seven_new_diy').html("<a href='./diy/index.html?BstartTime=-7&BendDate=0'>" + sevenNewDiy + "</a>");
            $('#seven_expired_diy').html("<a href='./diy/index.html?endDateType=7'>" + sevenExpiredDiy + "</a>");
            $('#expired_diy').html("<a href='./diy/index.html?endDateType=1'>" + expiredDiy + "</a>");
            $('#server_diy').html("<a href='./diy/index.html'>" + countDiy + "</a>");
        }
    });
}
